<?php namespace App\Http\Controllers;

use App\User as Alumni;
use App\Comment as Comment;
use Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;

use Request;

class AlumniController extends Controller {

	/*
	|--------------------------------------------------------------------------
	| Home Controller
	|--------------------------------------------------------------------------
	|
	| This controller renders your application's "dashboard" for users that
	| are authenticated. Of course, you are free to change or remove the
	| controller as you wish. It is just here to get your app started!
	|
	*/

	/**
	 * Create a new controller instance.
	 *
	 * @return void
	 */
	// public function __construct()
	// {
	// 	$this->middleware('auth');
	// }

	/**
	 * Show the application dashboard to the user.
	 *
	 * @return Response
	 */
	public function index()
	{
		return view('alumni.index');
	}

	public function batch11()
	{
		$alumni = Alumni::where('first_name', '!=', 'Admin')->where('batch', '=', '2011')->where('status', '=', '1')->get();
		return view('alumni.batch', compact('alumni'));
	}

	public function batch12()
	{
		$alumni = Alumni::where('first_name', '!=', 'Admin')->where('batch', '=', '2012')->where('status', '=', '1')->get();
		return view('alumni.batch', compact('alumni'));
	}

	public function batch13()
	{
		$alumni = Alumni::where('first_name', '!=', 'Admin')->where('batch', '=', '2013')->where('status', '=', '1')->get();
		return view('alumni.batch', compact('alumni'));
	}

	public function batch14()
	{
		$alumni = Alumni::where('first_name', '!=', 'Admin')->where('batch', '=', '2014')->where('status', '=', '1')->get();
		return view('alumni.batch', compact('alumni'));
	}

	public function profile($id)
	{
		$alum = Alumni::find($id);
		$comm = Comment::where('user_id', $id)->get();
		return view('alumni.profile', compact('alum', 'comm', 'id'));
	}

	public function comment($id)
	{
		$comment = Request::all();
		$comment['title'] = 'comment';
		$comment['user_id'] = $id;

		Comment::create($comment);

		return redirect('alumni');
	}

	public function destroy($id)
	{
		Comment::where('user_id', $id)->delete();
		Alumni::find($id)->delete();
		return redirect('alumni');
	}

	public function pending()
	{
		$pending = Alumni::where('first_name', '!=', 'Admin')->where('status', '=', '0')->get();
		return view('alumni.pending', compact('pending'));
	}

	public function store($id)
	{
		$active = Alumni::where('id', $id)->first();
		$active->status = '1';

		$active->update();
	}

}
